from PyQt5 import QtWidgets
from SalaryMainUI import Ui_MainWindow
from RecordSelect import SalaryRecordSelect
from RecordInsert import SalaryRecordInsert
from RecordUpdate import SalaryRecordUpdate
from RecordDelete import SalaryRecordDelete
from Cmd import Cmd
import sys


class SalaryMain(QtWidgets.QMainWindow,Ui_MainWindow):
    def __init__(self,username='test',dbpath='test.db'):
        super(SalaryMain,self).__init__()
        self.setupUi(self)
        
        self.username = username
        self.dbpath = dbpath
        self.setTitle()
        self.SelectRecordWindow = SalaryRecordSelect(self.username,self.dbpath)
        self.InsertRecordWindow = SalaryRecordInsert(self.username,self.dbpath)
        self.UpdateRecordWindow = SalaryRecordUpdate(self.username,self.dbpath)
        self.DeleteRecordWindow = SalaryRecordDelete(self.username,self.dbpath)
        self.CmdWindow = Cmd(self.username,self.dbpath)
        #logic
        self.actionSelect.triggered.connect(self.SelectRecordWindow.show)
        self.actionInsert.triggered.connect(self.InsertRecordWindow.show)
        self.actionUpdate.triggered.connect(self.UpdateRecordWindow.show)
        self.actionDelete.triggered.connect(self.DeleteRecordWindow.show)
        self.actionCMD.triggered.connect(self.CmdWindow.show)
        

    def setTitle(self):
        self.setWindowTitle("Welcome to %s's SalaryNotebook"%self.username)
        

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    salarymainwindow = SalaryMain(username='test',dbpath='test.db')
    salarymainwindow.show()
    sys.exit(app.exec())
    
